#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int xa,ya,xb,yb,xc,yc;
		cin>>xa>>ya>>xb>>yb>>xc>>yc;
		int x1,x2;
		x1=xa-xb;
		x2=xa-xc;
		int x=0;;
		if((ll)x1*x2>0)
		{
			x=min(abs(x1),abs(x2));
		}
		int y1,y2;
		y1=ya-yb;
		y2=ya-yc;
		int y=0;
		if((ll)y1*y2>0)
		{
			y=min(abs(y1),abs(y2));
		}
		cout<<y+x+1<<endl;
		
	}

	return 0;
}

